]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
location: Translate accuracy level for geoclue
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 11 Sep 2014 13:57:15 +0000 (14:57 +0100)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 11 Sep 2014 16:43:46 +0000 (17:43 +0100)
The enums values of geoclue have gaps in them (so more levels could be
added in future) but enum values of settings don't have such gaps so we
gotta translate between them.

Since desrt says that enums as integers in gsettings are bad, we now
treat accuracy level settings as string.

This fixes the recent regression of geoclue only allowing geiop level
accuracy to apps.

https://bugzilla.gnome.org/show_bug.cgi?id=736479

js/ui/status/location.js

index c6694d1a0f6fe280737f731444f63f58d672b136..9dc736eb71a2367e8f13ace55cb4cf00d12b5082 100644 (file)
@@ -13,6 +13,15 @@ const LOCATION_SCHEMA = 'org.gnome.system.location';
 const MAX_ACCURACY_LEVEL = 'max-accuracy-level';
 const ENABLED = 'enabled';
 
+const GeoclueAccuracyLevel = {
+    NONE: 0,
+    COUNTRY: 1,
+    CITY: 4,
+    NEIGHBORHOOD: 5,
+    STREET: 6,
+    EXACT: 8
+};
+
 var GeoclueIface = '<node> \
   <interface name="org.freedesktop.GeoClue2.Manager"> \
     <property name="InUse" type="b" access="read"/> \
@@ -181,10 +190,14 @@ const Indicator = new Lang.Class({
     },
 
     _getMaxAccuracyLevel: function() {
-        if (this._settings.get_boolean(ENABLED))
-            return this._settings.get_enum(MAX_ACCURACY_LEVEL);
-        else
-            return 0;
+        if (this._settings.get_boolean(ENABLED)) {
+            let level = this._settings.get_string(MAX_ACCURACY_LEVEL);
+
+            return GeoclueAccuracyLevel[level.toUpperCase()] ||
+                   GeoclueAccuracyLevel.NONE;
+        } else {
+            return GeoclueAccuracyLevel.NONE;
+        }
     },
 
     _notifyMaxAccuracyLevel: function() {